home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
The Atari Compendium
/
The Atari Compendium (Toad Computers) (1994).iso
/
files
/
umich
/
network
/
mail
/
mail110.lzh
/
INIT.C
< prev
next >
Wrap
C/C++ Source or Header
|
1994-02-25
|
6KB
|
190 lines
//=========================================================
//
// void init(char *version)
//
// Open mailer.rc (which must be in the current dir)
// and setup the global variables for:
//
// mailpath, mqueuepath, sequence, user, host, mail, reply,
// name, edit, from, sig.
//
// exit program if mailer.rc cannot be opened or the file
// either cannot be read or does not contain the required
// data.
//
//=========================================================
// $Id: init.c,v 1.5 1994/02/25 13:34:54 gbj Exp user $
/*
$Log: init.c,v $
* Revision 1.5 1994/02/25 13:34:54 gbj
* Tidy-up.
*
* Revision 1.4 1994/02/20 19:14:04 gbj
* Added mail aliasing.
*
* Revision 1.3 1994/02/14 23:36:52 gbj
* Incorporated changes for Alec Jones's outgoing mail log.
*
* Revision 1.2 1994/02/08 23:32:02 gbj
* First public release.
*
* Revision 1.1 1994/02/08 03:15:10 gbj
* Initial revision
*
*/
#include "mailer.h"
void init(char *version)
{
char *buf, *bp, *f1, *f2;
FILE *rc;
int err;
char logfile[128];
fprintf(stderr, "%s [G B JUDD]\n\n", version);
err=0;
rc=fopen("mailer.rc", "r");
if (rc == NULL)
{
fprintf(stderr, "\ninit: cannot open mailer.rc\n");
exit(1);
}
buf=(char*)malloc(128);
if (buf == NULL)
{
fprintf(stderr,
"\ninit: cannot allocate 128 bytes for buffer\n");
fclose(rc);
exit(1);
}
bp=fgets(buf, 127, rc);
if (bp == NULL)
{
fprintf(stderr, "\ninit: mailer.rc is empty\n");
exit(1);
}
*mailpath='\0';
*mqueuepath='\0';
*sequence='\0';
*mbox='\0';
*host='\0';
*reply='\0';
*from='\0';
*name='\0';
*edit='\0';
*mail='\0';
*sig='\0';
*logfile='\0';
*log='\0';
*alias='\0';
while (bp != NULL)
{
if (buf[0] != '#' && buf[0] != ' '
&& buf[0] != '\n') // comment
{
f1=strtok(buf, "=");
f2=strtok(NULL, "\n");
if (strcmp(f1, "user") == 0)
strcpy(user, f2);
else if (strcmp(f1, "host") == 0)
strcpy(host, f2);
else if (strcmp(f1, "mail") == 0)
strcpy(mail, f2);
else if (strcmp(f1, "reply") == 0)
strcpy(reply, f2);
else if (strcmp(f1, "name") == 0)
strcpy(name, f2);
else if (strcmp(f1, "edit") == 0)
strcpy(edit, f2);
else if (strcmp(f1, "sig") == 0)
strcpy(sig, f2);
else if (strcmp(f1, "log") == 0)
strcpy(logfile, f2);
else if (strcmp(f1, "alias") == 0)
strcpy(alias, f2);
}
bp=fgets(buf, 127, rc);
}
if (!*mail)
{
fprintf(stderr, "\ninit: no <mail> in mailer.rc\n");
err=1;
}
if (!*user)
{
fprintf(stderr, "\ninit: no <user> in mailer.rc\n");
err=1;
}
if(!*host)
{
fprintf(stderr, "\ninit: no <host> in mailer.rc\n");
err=1;
}
if(!*reply)
{
fprintf(stderr, "\ninit: no <reply> in mailer.rc\n");
err=1;
}
if(!*edit)
{
fprintf(stderr, "\ninit: no <edit> in mailer.rc\n");
err=1;
}
if (err)
{
free(buf);
fclose(rc);
exit(1);
}
strcpy(mailpath, mail);
strcat(mailpath, "\\mail");
strcpy(mqueuepath, mail);
strcat(mqueuepath, "\\mqueue");
strcpy(sequence, mqueuepath);
strcat(sequence, "\\sequence.seq");
strcpy(from, user);
strcat(from, "@");
strcat(from, host);
if (*logfile)
{
strcpy(log, mail);
strcat(log, "\\mail\\");
strcat(log, logfile);
}
if (*name)
{
strcat(from, " (");
strcat(from, name);
strcat(from, ")");
}
// fprintf(stderr, "user %s\n", user);
// fprintf(stderr, "host %s\n", host);
// fprintf(stderr, "mail %s\n", mail);
// fprintf(stderr, "reply %s\n", reply);
// fprintf(stderr, "name %s\n", name);
// fprintf(stderr, "edit %s\n\n", edit);
// fprintf(stderr, "from %s\n", from);
// fprintf(stderr, "sig %s\n", sig);
// fprintf(stderr, "mailpath %s\n", mailpath);
// fprintf(stderr, "mqueuepath %s\n", mqueuepath);
// fprintf(stderr, "sequence %s\n", sequence);
// fprintf(stderr, "log %s\n", log);
// fprintf(stderr, "alias %s\n", alias);
// fprintf(stderr, "\n");
free(buf);
fclose(rc);
return;
}